home *** CD-ROM | disk | FTP | other *** search
/ Workbench Design / WB Collection.iso / workbench werkzeuge / kickstart tools / kicka3000 / keepres.c < prev    next >
C/C++ Source or Header  |  1996-04-07  |  2KB  |  77 lines

  1. /* This code is in the public domain. It was written by Steve Holland
  2.    (sdh4@cornell.edu) It is placed here without copyright. */
  3.  
  4.  
  5. #include <exec/types.h>
  6. #include <exec/execbase.h>
  7. #include <exec/resident.h>
  8. #include <exec/memory.h>
  9. #include <proto/exec.h>
  10.  
  11.  
  12. extern struct ExecBase *SysBase;
  13.  
  14.  
  15. #define FASTMEM_MIN 0x7c00000
  16. #define FASTMEM_MAX 0x7efffff
  17. #define NEWROM_MIN  0x7f00000
  18. #define NEWROM_MAX  0x7f7ffff
  19. #define ARRAYSIZE 100
  20.  
  21. #define BASEINCREMENT 0x7000000
  22.  
  23. struct Resident **BasicArray; /* We start with BasicArray[2] in case we happen 
  24.  to be at the beginning of a memory segment, in which case we will be overwritten
  25.  by the free list on reset. Therefore the beginning of our data is &BasicArray[2] */
  26.  
  27. struct MemList *MyList;
  28.  
  29. void main(int argc,char *argv[])
  30. {
  31.   struct Resident **Array;
  32.   int ResCnt;
  33.   int Cnt,ArgCnt;
  34.   int AllocAbsSize;
  35.   APTR AllocAbsPtr;
  36.   APTR KickMemPtr;
  37.   APTR AllocBase;
  38.   struct MemEntry *MEArray;
  39.   
  40.   if (!argc) return;
  41.   
  42.   Array=(struct Resident **)SysBase->ResModules;
  43.   BasicArray=AllocMem(sizeof(struct Resident *)*ARRAYSIZE,MEMF_CLEAR|MEMF_PUBLIC|MEMF_CHIP);
  44.   if (!BasicArray) exit(1);
  45.   
  46.   for (Cnt=2,ArgCnt=1;argv[ArgCnt] && Cnt < (ARRAYSIZE-1);ArgCnt++) {
  47.     for (ResCnt=0;Array[ResCnt];ResCnt++) {
  48.       if (!strcmp(argv[ArgCnt],Array[ResCnt]->rt_Name)) {
  49.         BasicArray[Cnt]=(struct Resident *)(((ULONG)Array[ResCnt])+((ULONG)BASEINCREMENT));
  50.         Cnt++;
  51.         break;
  52.       }
  53.     }
  54.   }
  55.   BasicArray[Cnt]=NULL;
  56.   AllocAbsSize=sizeof(struct Resident *)*(Cnt);
  57.   AllocAbsPtr=(APTR)&BasicArray;
  58.   
  59.   AllocBase=AllocMem(1000+16+sizeof(struct MemList)+(2*sizeof(struct MemEntry)),MEMF_CLEAR|MEMF_CHIP|MEMF_PUBLIC);
  60.   if (!AllocBase) exit(10);
  61.   
  62.   MyList=(struct MemList *)(((char *)AllocBase)+8);
  63.   MEArray=&MyList->ml_ME[0];
  64.   MEArray[0].me_Un.meu_Addr=BasicArray;
  65.   MEArray[0].me_Length=ARRAYSIZE*sizeof(struct Resident *);
  66.   MEArray[1].me_Un.meu_Addr=AllocBase;
  67.   MEArray[1].me_Length=16+sizeof(struct MemList)+(2*sizeof(struct MemEntry));
  68.   MyList->ml_Node.ln_Succ=NULL;
  69.   MyList->ml_Node.ln_Pred=NULL;
  70.   MyList->ml_NumEntries=2;
  71.   Disable();
  72.   SysBase->KickMemPtr=MyList;
  73.   SysBase->KickTagPtr=&BasicArray[2];
  74.   SysBase->KickCheckSum=SumKickData();
  75.   Enable();
  76. }
  77.